<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {	
	$arrJson = array('error'=>1,'msg'=>$arrError[1]);
	echo $objRequest->getParam('callback') . '(' . Zend_Json::encode($arrJson) . ')';
	exit();
}
$intOfflineId	= $objRequest->getParam('offlineid', 0);
$intType		= $objRequest->getParam('type', 0);
$intError		= 0;
$objOffline		= new Offline();
$arrRow			= $objOffline->get($intOfflineId);
$arrOjoin		= $objOffline->getOjoin($AppUI->id,$intOfflineId);
if( isset($arrRow) && isset($arrRow['expired']) && (
						( $arrRow['userid'] == $AppUI->id && $AppUI->id )
						||
						(isset($arrOjoin) && $arrOjoin['statuses'] == 1)
					)
	){	
	$intTime		= time();
	$intTimeSub		= strtotime('-' . OFFLINE_RATED . ' day');
	$intTimeExp		= strtotime($arrRow['expired']);
	if($intTimeExp < $intTimeSub) {
		$intError = 59;
	}elseif($intTimeExp > $intTime) {
		$intError = 60;
	}
	if($intError == 0) {
		if($arrRow['userid'] == $AppUI->id && $AppUI->id && $intType == 1) {
			$arrAccept	= $objOffline->getAllForOjoin($intOfflineId, 3, 0, 500, $intTotal,1);
			$this->view->arrAccept	= $arrAccept;
		}
		$this->view->intOfflineId 	= $intOfflineId;
		$this->view->row 			= $arrRow;	
		$this->view->type 			= $intType;	
		$objView 	= Zend_Registry::get('objView');
		$strData	= $objView->fetch('ajax/ui-offline-rate.tpl');
		if(($intType == 1 && $intTotal == 0) || ($intType == 2 && ($arrOjoin['israte']&1)>0 && isset($arrOjoin))) {
			$intError = 61;
		}
	}
} else {
	$intError	= 1;	
}
if($intError > 0) {
	$strData	= $arrError[$intError];
}
$arrJson 		= array('error'=>$intError,'msg'=>$strData);
echo $objRequest->getParam('callback') . '(' . Zend_Json::encode($arrJson) . ')';
exit();
?>